from typing import List

from domain.note.typeDomain import TypeDomain
from util.aop.ormProxy import OrmProxy, Select, Insert, Update, Delete
from util.aop.proxy import ProxyFactory
from util.singleton import Singleton


@Singleton
@ProxyFactory(OrmProxy)
class TypeDao:
    @Select("""select type_id, type_name, parent_id, create_time
            from note_type""",
            List[TypeDomain])
    def list4Table(self, typeId):
        pass

    @Select("""select type_id, type_name, parent_id from note_type""",
            List[TypeDomain])
    def list(self):
        pass

    @Insert("""insert into note_type(type_name,parent_id) values(
    #{domain.typeName},#{domain.parentId})""")
    def add(self, domain: TypeDomain):
        pass

    @Update("""update note_type set 
    <if test="domain.typeName">type_name=#{domain.typeName},</if>
    <if test="domain.parentId">note_parent_id=#{domain.parentId},</if>
    type_id=type_id
    where type_id=#{domain.typeId}""")
    def update(self, domain: TypeDomain):
        pass

    @Delete("""delete from note_type where type_id=#{typeId}""")
    def delete(self, typeId):
        pass

